linux查找网站web目录和access.log

我相信很多人都会遇到找网站web目录的问题,那以webserver的类型来总结。

web目录

0x01. Kangle

kangle web服务器( 简称:kangle ) 是一款跨平台、轻量级,功能强大、易操作的高性能web服务器和反向代理服务器软件。

方法:

在网站上随便点,随意找一个非静态的web文件,比如goods.php
使用locate /goods.php
或者
在不支持locate的系统下使用find / -type f -name "/goods.php" 2>/dev/null

这种locate的方法也是通用的一种方法

0x02. nginx

1、ps -ef查看nginx的进程参数是否有-c
nginx: master process /www/server/nginx/sbin/nginx -c /www/server/nginx/conf/nginx.conf
这样根据/www/server/nginx/conf/的配置文件去读取web目录和access log

2、如果没有-c参数,那使用nginx -V命令,可以得到--conf-path=/etc/nginx/nginx.conf

再查看nginx.conf,搜索server关键字。如果nginx.conf没有server字符串,就查看vhosts或者conf.d里的conf是否含有server字符串,在server{}里就能找到access_log和wwwroot路径

注:有这样的情况:access_log和wwwroot不在同一个conf配置文件里

poc

0x03. httpd或者apache

httpd和apache我们统一认为是apache服务

1、通过locate httpd.conf查找网站配置文件,再搜索DocumentRoot查找web目录

[root@viarus ~]# locate httpd.conf
/etc/httpd/conf/httpd.conf
[root@viarus ~]# cat /etc/httpd/conf/httpd.conf | grep DocumentRoot
# DocumentRoot: The directory out of which you will serve your
DocumentRoot "/var/www/html"
# This should be changed to whatever you set DocumentRoot to.
#    DocumentRoot /www/docs/dummy-host.example.com

web目录:/var/www/html

2、通过find -type f -name xx.php或者locate xx.php命令查找网站特定的文件,可以快速的查找web目录

3、通过httpd -V,程序写代码使用的方法

[root@viarus ~]# httpd -V
Server version: Apache/2.2.15 (Unix)
Server built:   Mar 22 2016 19:03:53
Server's Module Magic Number: 20051115:25
Server loaded:  APR 1.3.9, APR-Util 1.3.9
Compiled using: APR 1.3.9, APR-Util 1.3.9
Architecture:   64-bit
Server MPM:     Prefork
  threaded:     no
    forked:     yes (variable process count)
Server compiled with....
 -D APACHE_MPM_DIR="server/mpm/prefork"
 -D APR_HAS_SENDFILE
 -D APR_HAS_MMAP
 -D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)
 -D APR_USE_SYSVSEM_SERIALIZE
 -D APR_USE_PTHREAD_SERIALIZE
 -D SINGLE_LISTEN_UNSERIALIZED_ACCEPT
 -D APR_HAS_OTHER_CHILD
 -D AP_HAVE_RELIABLE_PIPED_LOGS
 -D DYNAMIC_MODULE_LIMIT=128
 -D HTTPD_ROOT="/etc/httpd"
 -D SUEXEC_BIN="/usr/sbin/suexec"
 -D DEFAULT_PIDLOG="run/httpd.pid"
 -D DEFAULT_SCOREBOARD="logs/apache_runtime_status"
 -D DEFAULT_LOCKFILE="logs/accept.lock"
 -D DEFAULT_ERRORLOG="logs/error_log"
 -D AP_TYPES_CONFIG_FILE="conf/mime.types"
 -D SERVER_CONFIG_FILE="conf/httpd.conf"

将HTTPD_ROOT和SERVER_CONFIG_FILE组合起来,即/etc/httpd/conf/httpd.conf

access.log

0x01 nginx

1、通过查看进程目录下面的fd目录ls -la /proc/pid/fd

[root@viarus ~]# ps -ef | grep nginx
root      7175  7045  0 10:30 pts/0    00:00:00 grep nginx
root      8938     1  0 Mar25 ?        00:00:00 nginx: master process nginx
nginx     8939  8938  0 Mar25 ?        00:00:00 nginx: worker process
[root@viarus ~]# ll /proc/8939/fd
total 0
lrwx------ 1 nginx nginx 64 May  4 10:25 0 -> /dev/null
lrwx------ 1 nginx nginx 64 May  4 10:25 1 -> /dev/null
l-wx------ 1 nginx nginx 64 May  4 10:25 2 -> /var/log/nginx/error.log
l-wx------ 1 nginx nginx 64 May  4 10:25 3 -> /var/log/nginx/access.log

结果:/var/log/nginx/access.log

2、使用nginx -V poc

0x02 apache

1、通过查看进程目录下面的fd目录ls -la /proc/pid/fd

[root@viarus ~]# ps -ef | grep httpd
root      7094     1  0 09:59 ?        00:00:00 /usr/sbin/httpd
apache    7096  7094  0 09:59 ?        00:00:00 /usr/sbin/httpd
apache    7097  7094  0 09:59 ?        00:00:00 /usr/sbin/httpd
apache    7098  7094  0 09:59 ?        00:00:00 /usr/sbin/httpd
apache    7099  7094  0 09:59 ?        00:00:00 /usr/sbin/httpd
apache    7100  7094  0 09:59 ?        00:00:00 /usr/sbin/httpd
apache    7101  7094  0 09:59 ?        00:00:00 /usr/sbin/httpd
apache    7102  7094  0 09:59 ?        00:00:00 /usr/sbin/httpd
apache    7103  7094  0 09:59 ?        00:00:00 /usr/sbin/httpd
root      7179  7045  0 10:35 pts/0    00:00:00 grep httpd
[root@viarus ~]# ll /proc/7096/fd
total 0
lr-x------ 1 root root 64 May  4 10:35 0 -> /dev/null
l-wx------ 1 root root 64 May  4 10:35 1 -> /dev/null
l-wx------ 1 root root 64 May  4 10:35 2 -> /var/log/httpd/error_log
lrwx------ 1 root root 64 May  4 10:35 3 -> socket:[1313779]
lr-x------ 1 root root 64 May  4 10:35 4 -> pipe:[1313798]
l-wx------ 1 root root 64 May  4 10:35 5 -> pipe:[1313798]
l-wx------ 1 root root 64 May  4 10:35 6 -> /var/log/httpd/access_log

结果:/var/log/httpd/access_log

results matching ""

    No results matching ""